package com.yanqu.road.server.manager.activity.apprentice.handler.impl;

import com.yanqu.road.entity.activity.apprentice.ApprenticeEffectBuffProject;
import com.yanqu.road.entity.activity.apprentice.config.ApprenticeProjectConfig;
import com.yanqu.road.entity.activity.apprentice.data.ApprenticeBuffProjectData;
import com.yanqu.road.entity.enums.eOccupationType;
import com.yanqu.road.server.manager.activity.apprentice.handler.ApprenticeProjectHandler;
import com.yanqu.road.server.manager.activity.apprentice.handler.param.ApprenticeCountSortAddRateReq;
import com.yanqu.road.server.manager.activity.apprentice.handler.param.ApprenticeCountTalentAddRateReq;
import com.yanqu.road.server.manager.activity.apprentice.handler.param.ApprenticeDoProjectReq;
import com.yanqu.road.server.manager.activity.apprentice.handler.param.ApprenticeDoProjectResp;

import java.util.List;
import java.util.Map;

public class ApprenticeDoProjectType14Handler implements ApprenticeProjectHandler {

    /**
     * 执行项目
     * @param req
     * @return
     */
    @Override
    public ApprenticeDoProjectResp doProject(ApprenticeDoProjectReq req) {
        return null;
    }

    /**
     * 本次行程，你所选择的项目将在执行时重新随机，获得的天资{0}。
     * @param req
     */
    @Override
    public void countTalentTypeAddRate(ApprenticeCountTalentAddRateReq req) {
        ApprenticeProjectConfig projectConfig = req.getProjectConfig();
        Map<Integer, Integer> resultMap = req.getResultMap();
        ApprenticeBuffProjectData buffProjectData = req.getBuffProjectData();
        //buff次数减一
        buffProjectData.addNum(-1);
        //加成
        int addRate = Integer.parseInt(projectConfig.getParam()) - 1000;
        //注入加成值到MAP
        for (eOccupationType type : eOccupationType.values()) {
            int talentType = type.getValue();
            int oldRate = resultMap.getOrDefault(talentType, 0);
            resultMap.put(talentType, oldRate + addRate);
        }
        //生效buff结果结果集注入
        List<ApprenticeEffectBuffProject> effectBuffProjects = req.getEffectBuffProjects();
        ApprenticeEffectBuffProject effectBuffProject = new ApprenticeEffectBuffProject(buffProjectData.getProjectId(), addRate);
        effectBuffProjects.add(effectBuffProject);
    }

    @Override
    public void countSortTypeAddRate(ApprenticeCountSortAddRateReq req) {

    }
}
